cmake_minimum_required(VERSION 3.28)
project(JTT809)
set(CMAKE_CXX_STANDARD 23)

if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/cmake/xrepo.cmake")
    message(STATUS "Downloading xrepo.cmake from https://github.com/xmake-io/xrepo-cmake/")
    # mirror https://cdn.jsdelivr.net/gh/xmake-io/xrepo-cmake@main/xrepo.cmake
    file(DOWNLOAD "https://raw.githubusercontent.com/xmake-io/xrepo-cmake/main/xrepo.cmake"
            "${CMAKE_CURRENT_LIST_DIR}/cmake/xrepo.cmake"
            TLS_VERIFY ON)
endif()

# Include xrepo.cmake so we can use xrepo_package function.
include(${CMAKE_CURRENT_LIST_DIR}/cmake/xrepo.cmake)
xrepo_package("boost" DIRECTORY_SCOPE)
xrepo_package("spdlog" DIRECTORY_SCOPE)

message(STATUS "${spdlog_INCLUDE_DIRS}")

add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
set(CMAKE_BUILD_TYPE Debug) # 或者 Release
include(${CMAKE_CURRENT_LIST_DIR}/cmake/BuildConfig.cmake)

link_libraries(ws2_32)

add_executable(JTT809 main.cpp
        protocol/msgpack/messagepack_reader.h
        protocol/msgpack/messgepack_reader.cpp
        protocol/msgpack/MessagePackWriter.h
        protocol/msgpack/MessagePackWriter.cpp
        protocol/exception/jtt809_exception.h
        protocol/exception/jtt809_exception.cpp
        protocol/exception/jtt809_errcode.h
        jtt809_logger.h
        protocol/util/utils.h
        protocol/jtt809_body.h
        protocol/enums/jtt809_linktype.h
        protocol/jtt809_header.cpp
        protocol/jtt809_header.h
        protocol/jtt809_packet.h
        protocol/interfaces/base.h
        protocol/msgbody/jtt809_0x1001.cpp
        protocol/msgbody/jtt809_0x1001.h
        protocol/util/constants.h
        "protocol/jtt809_config.h"
        protocol/msgbody/jtt809_0x1002.cpp
        protocol/msgbody/jtt809_0x1002.h
        protocol/enums/jtt809_0x1002_result.h
        protocol/msgbody/jtt809_0x1003.cpp
        protocol/msgbody/jtt809_0x1003.h
        protocol/msgbody/jtt809_0x1004.h
        protocol/msgbody/jtt809_0x1005.h
        protocol/msgbody/jtt809_0x1006.h
        protocol/msgbody/jtt809_0x1007.h
        protocol/msgbody/jtt809_0x1008.h
        protocol/msgbody/JTT809_0x9001.h
        protocol/msgbody/jtt809_0x9002.h
        protocol/enums/jtt809_0x9002_result.h
        protocol/msgbody/jtt809_0x9003.h
        protocol/msgbody/jtt809_0x9004.h
        protocol/msgbody/jtt809_0x9005.h
        protocol/msgbody/empty_body.h
        protocol/msgbody/jtt809_0x9006.h
        protocol/msgbody/jtt809_0x9007.h
        protocol/enums/jtt809_0x9007_errcode.h
        protocol/msgbody/jtt809_0x9008.h
        protocol/enums/jtt809_0x9008_reasoncode.h
        protocol/msgbody/jtt809_0x9101.cpp
        protocol/msgbody/jtt809_0x9101.h
        protocol/msgbody/jtt809_0x9102.cpp
        protocol/msgbody/jtt809_0x9102.h
        protocol/msgbody/JTT809_0x1102.cpp
        protocol/msgbody/JTT809_0x1102.h
        protocol/msgbody/jtt809_0x1103.cpp
        protocol/msgbody/jtt809_0x1103.h
        protocol/msgbody/jtt809_0x9103.h
        protocol/msgbody/submsgbody/jtt809_sub_body.h
        protocol/msgbody/jtt809_0x1200.h
        protocol/msgbody/jtt809_0x9200.h
        protocol/msgbody/jtt809_0x1300.h
        protocol/msgbody/jtt809_0x9300.h
        protocol/msgbody/jtt809_0x1400.h
        protocol/msgbody/jtt809_0x9400.h
        protocol/msgbody/jtt809_0x1500.h
        protocol/msgbody/jtt809_0x9500.h
        protocol/msgbody/jtt809_exchange_msg.h
        protocol/msgbody/jtt809_0x1600.h
        protocol/msgbody/jtt809_0x9600.h
        protocol/msgbody/submsgbody/jtt809_0x1201.cpp
        protocol/msgbody/submsgbody/jtt809_0x1201.h
        protocol/msgbody/submsgbody/vehicle_positioning_info.cpp
        protocol/msgbody/submsgbody/vehicle_positioning_info.h
        protocol/util/types.h
        protocol/msgbody/submsgbody/jtt809_0x1202.h
        protocol/msgbody/submsgbody/jtt809_0x1203.h
        protocol/msgbody/submsgbody/jtt809_0x1205.h
        protocol/msgbody/submsgbody/jtt809_0x1206.h
        protocol/msgbody/submsgbody/jtt809_0x1207.h
        protocol/msgbody/submsgbody/jtt809_0x1208.h
        protocol/msgbody/submsgbody/jtt809_0x1209.h
        protocol/msgbody/submsgbody/jtt809_0x120a.cpp
        protocol/msgbody/submsgbody/jtt809_0x120a.h
        protocol/msgbody/submsgbody/jtt809_0x120b.cpp
        protocol/msgbody/submsgbody/jtt809_0x120b.h
        protocol/util/concepts.h
        protocol/msgbody/submsgbody/jtt809_0x120c.cpp
        protocol/msgbody/submsgbody/jtt809_0x120c.h
        protocol/util/macros.h
        protocol/msgbody/submsgbody/jtt809_0x120d.h
        protocol/properties/inflection_point.h
        protocol/properties/route.h
        protocol/msgbody/submsgbody/jtt809_0x120e.h
        protocol/enums/jtt809_0x9201_result.h
        protocol/msgbody/submsgbody/jtt809_0x9201.h
        protocol/msgbody/submsgbody/jtt809_0x9202.h
        protocol/msgbody/submsgbody/jtt809_0x9203.h
        protocol/msgbody/submsgbody/jtt809_0x9204.h
        protocol/msgbody/submsgbody/jtt809_0x9205.h
        protocol/enums/jtt809_0x9205_reasoncode.h
        protocol/msgbody/submsgbody/jtt809_0x9206.h
        protocol/enums/jtt809_0x9206_reasoncode.h
        protocol/msgbody/submsgbody/jtt809_0x9207.h
        protocol/enums/jtt809_0x9207_result.h
        protocol/enums/jtt809_0x9208_result.h
        protocol/msgbody/submsgbody/jtt809_0x9208.h
        protocol/msgbody/submsgbody/jtt809_0x9209.h
        protocol/enums/jtt809_0x9209_result.h
        protocol/msgbody/submsgbody/jtt809_0x920a.h
        protocol/msgbody/submsgbody/jtt809_0x920b.h
        protocol/msgbody/submsgbody/jtt809_0x920c.h
        protocol/msgbody/submsgbody/jtt809_0x920d.h
        protocol/enums/jtt809_0x920d_result.h
        protocol/msgbody/submsgbody/jtt809_0x1301.cpp
        protocol/msgbody/submsgbody/jtt809_0x1301.h
        protocol/msgbody/submsgbody/jtt809_0x1302.h
        protocol/msgbody/submsgbody/jtt809_0x1303.h
        protocol/msgbody/submsgbody/jtt809_0x9301.h
        protocol/msgbody/submsgbody/jtt809_0x9302.h
        protocol/msgbody/submsgbody/jtt809_0x9303.h
        protocol/msgbody/submsgbody/jtt809_0x1401.h
        protocol/enums/jtt809_alarm_result.h
        protocol/msgbody/submsgbody/jtt809_0x1402.h
        protocol/msgbody/submsgbody/jtt809_0x1411.h
        protocol/msgbody/submsgbody/jtt809_0x1412.h
        protocol/msgbody/submsgbody/jtt809_0x9401.h
        protocol/msgbody/submsgbody/jtt809_0x9402.h
        protocol/msgbody/submsgbody/jtt809_0x9403.h
        protocol/msgbody/submsgbody/jtt809_0x1403.h
        protocol/msgbody/submsgbody/jtt809_0x1413.h
        protocol/msgbody/submsgbody/jtt809_0x1501.h
        protocol/msgbody/submsgbody/jtt809_0x1502.h
        protocol/enums/jtt809_0x1502_photo_rsp_flag.h
        protocol/enums/image_size.h
        protocol/enums/image_format.h
        protocol/msgbody/submsgbody/jtt809_0x1503.h
        protocol/msgbody/submsgbody/jtt809_0x1504.h
        protocol/msgbody/submsgbody/jtt809_0x1505.h
        protocol/enums/jtt809_0x1505_result.h
        protocol/msgbody/submsgbody/jtt809_0x9501.h
        protocol/msgbody/submsgbody/jtt809_0x9502.h
        protocol/msgbody/submsgbody/jtt809_0x9503.h
        protocol/msgbody/submsgbody/jtt809_0x9504.h
        protocol/msgbody/submsgbody/jtt809_0x9505.h
        protocol/msgbody/submsgbody/jtt809_0x1602.h
        protocol/msgbody/submsgbody/jtt809_0x1601.h
        protocol/msgbody/submsgbody/jtt809_0x9601.h
        protocol/msgbody/jtt809_interaction_msg.h
        protocol/msgbody/bodies_pch.h
        protocol/msgbody/submsgbody/sub_bodies_pch.h
        protocol/msgbody/message_body_factory.h
        protocol/msgbody/submsgbody/sub_message_body_factory.h
        network/server.hpp
        network/client.hpp
        network/gateway.hpp
        protocol/protocol.hpp
        network/message_factory.hpp
        network/superior.hpp
        network/utils.hpp
        network/inferior.hpp
        network/common.hpp
        network/base.hpp
)


# ---------------------------------------------------------------------------------------
# Example of using pre-compiled library
# ---------------------------------------------------------------------------------------
#target_link_libraries(JTT809 PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
